import request from "@/utils/request"

export default {

     findUserById: (userId) => {
        return request.get(`/user/${userId}`)
    }

    , searchUser: (keyword) => {
        return request.get(`/contact/search?kw=${keyword}`)
    }

    , applyFriend: (userId) => {
        return request.post(`/contact/apply/${userId}`)
    }

    , deleteFriend: (userId) => {
        return request.delet(`/contact/friend/${userId}`)
    }

    , agreedFriend: (userId) => {
        return request.put(`/contact/agreed/${userId}`)
    }

    , refuseFriend: (userId) => {
        return request.put(`/contact/refuse/${userId}`)
    }

    , addToBlack: (userId) => {
        return request.put(`/contact/black/${userId}`)
    }

    , removeFromBlack: (userId) => {
        return request.delet(`/contact/black/${userId}`)
    }

    ,findConvIdsByChatuser: (chatuser)=> {
        return request.get(`/chat/conversations/${chatuser}`)
    }
    //获取聊天信息流
    ,findConversationById: (convId)=> {
        return request.get(`/chat/conversation/${convId}`)
    }
    /**
     * 获取联系人列表
     */
    ,findContactList: () => {
        return request.get(`/contact/list/current`)
    }

    /**
     * 获取聊天列表
     */
    ,findChatterRelationList: () => {
        return request.get(`/chat/chatters/current`)
        // return new Promise((resolve, reject) => {
        //     resolve({
        //         ok:true,
        //         msg: "",
        //         data: []
        //     })
        // });
    }
    /**
     * 获取群组列表
     */
     ,findChatGroupList: () => {
        return request.get(`/chat/group/list`)
        // return new Promise((resolve, reject) => {
        //     resolve({
        //         ok:true,
        //         msg: "",
        //         data: []
        //     })
        // });
    }
    // /**
    //  * 获取群组列表
    //  */
    // ,findChatGroupList: () => {
    //     return request.get(`/chat/group/list`)
    //     // return new Promise((resolve, reject) => {
    //     //     resolve({
    //     //         ok:true,
    //     //         msg: "",
    //     //         data: []
    //     //     })
    //     // });
    // }

    /**
     * 获取好友申请列表
     */
    ,applyFriendList: () => {
        return request.get(`/contact/apply/list`)
    }

    /**
     * 清空好友申请列表
     * @returns {Promise | Promise<unknown>}
     */
    ,clearApplyList:() => {
        return request.post(`/contact/clear-apply/all`)
    }

    , findMessageList: (chatter,isGroup,beforeTime) => {
        return request.get(`/chat/messages/current`,{chatter:chatter,isGroup:isGroup,beforeTime:beforeTime})
    }

}